<%@ page language="java" isELIgnored="false"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=8,IE=9,IE=10,IE=11" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Cache-Control" content="no-store">
<title>Insert title here</title>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
	<script src="/admin/public/html5shiv.min.js"></script>
	<script src="/admin/public/respond.min.js"></script>
<![endif]-->
<!-- Bootstrap core CSS -->
<link href="/admin/public/bootstrap.min.css" title="" rel="stylesheet" />
<link href="/admin/font-awesome/css/font-awesome.min.css"
	rel="stylesheet" />
<!-- 时间控件样式 -->
<link
	href="/admin/css/plugins/datetimepicker/bootstrap-datetimepicker.min.css"
	rel="stylesheet" media="screen">
<link rel="stylesheet" href="/admin/css/templet_form.css" />
	
	
	
<link href="/admin/public/animate.css" rel="stylesheet" />
<link rel="stylesheet" href="/admin/public/inspinia.css" />
<link rel="stylesheet" href="/admin/css/pop-up.css" />
<link rel="stylesheet" href="/admin/css/plugins/toastr/toastr.min.css" />
<link rel="stylesheet" type="text/css"
	href="${request.getContext }/admin/css/xcConfirm.css" />
<script src="/admin/My97/WdatePicker.js"></script>
<script type="text/javascript" charset="utf-8" src="/admin/js/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/admin/js/ueditor.all.js"> </script>
<script type="text/javascript" charset="utf-8" src="/admin/js/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="/admin/js/ueditor.all.min.js"></script>
<style type="text/css">
.img{
	height: 214px;
	width:640px;
}
</style>
</head>
<body>
	<div id="wrapper" class="container">
		<div class="wrapper wrapper-content">
			<div class="right_box">
				<div style="border: none; box-shadow: none;" class="right_one row">
					<div class="col-md-12 col-sm-12 col-xs-12" style="float: left;">
						<form class="form-horizontal" method="post" id="savecourses" enctype="multipart/form-data"
							novalidate="novalidate">
							<input value="2" name="coursesType" type="hidden" />
							<input value="${coursesInfoId }" name="coursesInfoId" type="hidden" />
							<input value="${picUrl }" name="oldPicUrl" type="hidden" />
							<div class="form-group">
								<label class="col-lg-2 control-label">训练营名称:</label>
								<div class="col-lg-6">
									<input type="text" class="form-control" id="coursesName"
										name="coursesName" value="${coursesName }"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">门店名称:</label>
								<div class="col-lg-6">
									<select class="select2_demo_1 form-control" name="xlyshopId"
										id="xlyshopId">
										<option value="">--请选择--</option>
										<c:forEach items="${shop.shopList }" var="shop">
											<option value="${shop.shopId }" ${xlyshopId==shop.shopId?'selected':'' }>${shop.shopName }</option>
										</c:forEach>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">时长(分钟):</label>
								<div class="col-lg-6">
									<input onkeyup="value=value.replace(/[^0-9]/g,&#39;&#39;);" type="text" class="form-control" id="minTime"
										name="minTime" value="${minTime }"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">可报名人数:</label>
								<div class="col-lg-6">
									<input onkeyup="value=value.replace(/[^0-9]/g,&#39;&#39;);" type="text" class="form-control" id="maxNum"
										name="maxNum" value="${maxNum }"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">最少报名人数:</label>
								<div class="col-lg-6">
									<input onkeyup="value=value.replace(/[^0-9]/g,&#39;&#39;);" type="text" class="form-control" id="minNum" name="minNum"
										value="${minNum }"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">普通价（元）:</label>
								<div class="col-lg-6">
									<%-- <input onkeyup="value=value.replace(/[^0-9]/g,&#39;&#39;);" type="text" class="form-control" id="ptj" name="ptj"
										value="${ptj }"/> --%>
									<input onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')" 
									type="text" class="form-control" id="ptj" name="ptj" value="${ptj }"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">会员价（元）:</label>
								<div class="col-lg-6">
									<%-- <input onkeyup="value=value.replace(/[^0-9]/g,&#39;&#39;);" type="text" class="form-control" id="hyj" name="hyj"
										value="${hyj }"/> --%>
									<input onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')" 
									type="text" class="form-control" id="hyj" name="hyj" value="${hyj }"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">背景图片:</label>
								<div class="col-lg-6">
									<input type="file" class="form-control" id="picUrl"
										name="picUrl" value="${picUrl }" onchange="preview(this,1)">
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label"></label>
								<div class="col-lg-6">
									<span style="color:red;">建议图片尺寸：640*214</span>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label"></label>
								<div class="col-lg-6">
									<div id="preview1">
										<img src="${picUrl }" alt="" height="214px" width="640px"/>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">上课时间:</label>
								<div class="col-lg-6">
									<input type="text" class="form-control" id="xlyke"
										name="xlyke" value="${xlyke }"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">如何上课:</label>
								<div class="col-lg-6">
									<div>
										<script id="editor" type="text/plain" name="rhsk" class="rhsk"  style="width:504px;height:200px;"></script>
									</div>
										<input type="hidden" id="mainContent" name="mainContent">
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">课程标签:</label>
								<div class="col-lg-6">
									<textarea  rows="3" cols="3" class="form-control" id="jianjie"
										name="jianjie" >${jianjie }</textarea>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">开始时间:</label>
								<div class="col-lg-6">
									<div class="date input-append form_date ymd_date"
										id="addtimeCalendar" style="float: left; margin-right: 5px;">
										<div class="input-group">
											<input class="form-control input-sm" type="text"
												name="xlystartTime" id="xlystartTime" value="${xlystartTime }"> <span
												class="add-on input-group-addon"
												style="position: relative; left: -40px;"> <i
												class="fa fa-calendar" style="color: black;"></i>
											</span>
										</div>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-2 control-label">结束时间:</label>
								<div class="col-lg-6">
									<div class="date input-append form_date ymd_date"
										id="addtimeCalendar" style="float: left; margin-right: 5px;">
										<div class="input-group">
											<input class="form-control input-sm" type="text"
												name="xlyendTime" id="xlyendTime" value="${xlyendTime }"> <span
												class="add-on input-group-addon"
												style="position: relative; left: -40px;"> <i
												class="fa fa-calendar" style="color: black;"></i>
											</span>
										</div>
									</div>
								</div>
							</div>
							<input type="button" onclick="savecourses();" id="btnn" style="display: none"/>
							<input type="button" onclick="update();" id="xiugai" style="display: none"/>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script src="/admin/public/jquery-1.11.3.js"></script>
	<script src="/admin/public/bootstrap.min.js" type="text/javascript"></script>
	<script src="${request.getContext }/admin/js/xcConfirm.js"
		type="text/javascript" charset="utf-8"></script>
	<script src="/admin/js/plugins/toastr/toastr.min.js"></script>
	<script src="/admin/js/new_page.js"></script>
	<!-- 时间控件样式 -->
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker.min.js"></script>
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker-update.min.js"></script>
	<script
		src="/admin/js/plugins/datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>
		<script src="/admin/js/jquery.form.min.js"></script>
	<script type="text/javascript">
		function preview(file, i) {
			var prevDiv = document.getElementById('preview' + i);
			if (file.files && file.files[0]) {
				var reader = new FileReader();
				reader.onload = function(evt) {
					prevDiv.innerHTML = '<img class="img" src="' + evt.target.result + '" />';
				}
				reader.readAsDataURL(file.files[0]);
			} else {
				prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
			}
		}
	</script>
	<script>
	$(function(){
		$('.ymd_date').datetimepicker({　
			minView: "month",
			format: "yyyy-mm-dd",
			language: 'zh-CN',
			autoclose: true,
			pickerPosition: "bottom-left",
			
		});
	})
		function check() {
			var coursesName = $("#coursesName").val();
			var minTime = $("#minTime").val();
			var minNum = $("#minNum").val();
			var maxNum=$("#maxNum").val();
			var xlystartTime=$("#xlystartTime").val();
			var xlyendTime=$("#xlyendTime").val();
			var xlyshopId=$("#xlyshopId option:selected").val();
			var xlyke=$("#xlyke").val();
			if(parseInt(minNum)>parseInt(maxNum)){
				alertNew('最少报名人数不能大于可报名人数！', false);
				return false;
			}
			if (coursesName.length == 0) {
				alertNew('请输入训练营名称！', false);
				return false;
			}
			if (minTime.length == 0) {
				alertNew('请输入最少时长！', false);
				return false;
			}
			if (maxNum.length == 0) {
				alertNew('请输入单节课可约人数！', false);
				return false;
			}
			if (minNum.length == 0) {
				alertNew('请输入最少上课人数！', false);
				return false;
			}
			if (ptj.length == 0) {
				alertNew('请输入普通会员价格！', false);
				return false;
			}
			if (hyj.length == 0) {
				alertNew('请输入会员价格！', false);
				return false;
			}
			if (xlyke.length == 0) {
				alertNew('请输入上课时间！', false);
				return false;
			}
			if (xlyshopId.length == 0) {
				alertNew('请选择训练营门店！', false);
				return false;
			}
			if (xlystartTime.length == 0) {
				alertNew('请输入训练营开始时间！', false);
				return false;
			}
			if (xlyendTime.length == 0) {
				alertNew('请输入训练营结束时间！', false);
				return false;
			}
			if (xlyendTime<xlystartTime) {
				alertNew('开始时间不能大于结束时间', false);
				return false;
			}
			return true;
		}
		//添加
		function savecourses() {
			if (check()) {
				$('#savecourses').ajaxSubmit({
					type : "post",
					data : $("#savecourses").serialize(),
					enctype:"multipart/form-data",
					dataType : "json",
					url : "/courses/addInfo",
					success : function(data) {
						if (data.success) {
							window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.info,{onOk:function(){ 
								$('#ifr', window.parent.document).attr('src',
								'/courses/cournfo?coursesType=2');
					  		}})
						}else{
							alertNew(data.msg, false);
						}
					},
					error : function(data) {
						alert("很抱歉，未知的错误发生了！");
					}
				});
			}
		}
		//修改
		function update() {
			if (check()) {
				$('#savecourses').ajaxSubmit({
					type : "post",
					data : $("#savecourses").serialize(),
					dataType : "json",
					enctype:"multipart/form-data",
					url : "/courses/updatecourses",
					success : function(data) {
						if (data.success) {
							window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.info,{onOk:function(){ 
								$('#ifr', window.parent.document).attr('src',
								'/courses/cournfo?coursesType=2');
					  		}})
						}else{
							alertNew(data.msg, false);
						}
					},
					error : function(data) {
						alert("很抱歉，未知的错误发生了！");
					}
				});
			}
		}
		 /**文本编辑器**/
        //实例化编辑器
 //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
  var ue = UE.getEditor('editor', {
 	 	"imageActionName": "uploadimage", /* 执行上传图片的action名称 */
 	    "imageFieldName": "upfile", /* 提交的图片表单名称 */
 	    "imageMaxSize": 2048000, /* 上传大小限制，单位B */
 	    "imageAllowFiles": [".png", ".jpg", ".jpeg", ".gif", ".bmp"], /* 上传图片格式显示 */
 	    "imageCompressEnable": false, /* 是否压缩图片,默认是true */
 	    "imageCompressBorder": 1600, /* 图片压缩最长边限制 */
 	    "imageInsertAlign": "none", /* 插入的图片浮动方式 */
 	    "imageUrlPrefix": "", /* 图片访问路径前缀 */
 	    "imagePathFormat": "/upload/content/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
 	                                /* {filename} 会替换成原文件名,配置这项需要注意中文乱码问题 */
 	                                /* {rand:6} 会替换成随机数,后面的数字是随机数的位数 */
 	                                /* {time} 会替换成时间戳 */
 	                                /* {yyyy} 会替换成四位年份 */
 	                                /* {yy} 会替换成两位年份 */
 	                                /* {mm} 会替换成两位月份 */
 	                                /* {dd} 会替换成两位日期 */
 	                                /* {hh} 会替换成两位小时 */
 	                                /* {ii} 会替换成两位分钟 */
 	                                /* {ss} 会替换成两位秒 */
 	                                /* 非法字符 \ : * ? " < > | */
 	                                /* 具请体看线上文档: fex.baidu.com/ueditor/#use-format_upload_filename */
 	                                
			    	   /* 上传视频配置 */
			    "videoActionName": "uploadvideo", /* 执行上传视频的action名称 */
			    "videoFieldName": "upfile", /* 提交的视频表单名称 */
			    "videoPathFormat": "/upload/content/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
			    "videoUrlPrefix": "", /* 视频访问路径前缀 */
			    "videoMaxSize": 734003200, /* 上传大小限制，单位B，默认100MB 此处限制700M*/
			    "videoAllowFiles": [
			        ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
			        ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid"], /* 上传视频格式显示 */
 	        
 	        /* 上传文件配置 */
 	        "fileActionName": "uploadfile", /* controller里,执行上传视频的action名称 */
 	        "fileFieldName": "upfile", /* 提交的文件表单名称 */
 	        "filePathFormat": "/upload/content/{yyyy}{mm}{dd}/{time}{rand:6}", /* 上传保存路径,可以自定义保存路径和文件名格式 */
 	        "fileUrlPrefix": "", /* 文件访问路径前缀 */
 	        "fileMaxSize": 51200000, /* 上传大小限制，单位B，默认50MB */
 	        "fileAllowFiles": [
 	            ".png", ".jpg", ".jpeg", ".gif", ".bmp",
 	            ".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
 	            ".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
 	            ".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
 	            ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
 	        ], /* 上传文件格式显示 */
 	        serverUrl: '/admin/content/uploadimage'
 });
	</script>
</body>
</html>
